<!DOCTYPE html>
<html lang=zh>
<head>
    <!-- so meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="HandheldFriendly" content="True">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5" />
    <meta name="description" content="Maven1.Maven简介和快速入门1.1Maven介绍 Maven是一款为Java项目构建管理，依赖管理的工具（软件），使用Maven可以自动化构建、测试、打包和发布项目，大大提高了开发效率和质量 总结：Maven就是一个软件，掌握软件安装、配置、以及基本功能（项目构建、依赖管理）使用就是本课程的主要目标！  1.2Maven主要作用理解 场景概念： 场景1：例如我们项目需要第三方库（依赖），">
<meta property="og:type" content="article">
<meta property="og:title" content="Maven">
<meta property="og:url" content="https://mihaoyou.gitee.io/Maven/index.html">
<meta property="og:site_name" content="Cactus">
<meta property="og:description" content="Maven1.Maven简介和快速入门1.1Maven介绍 Maven是一款为Java项目构建管理，依赖管理的工具（软件），使用Maven可以自动化构建、测试、打包和发布项目，大大提高了开发效率和质量 总结：Maven就是一个软件，掌握软件安装、配置、以及基本功能（项目构建、依赖管理）使用就是本课程的主要目标！  1.2Maven主要作用理解 场景概念： 场景1：例如我们项目需要第三方库（依赖），">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-09-15T13:40:13.000Z">
<meta property="article:modified_time" content="2023-09-18T14:15:33.172Z">
<meta property="article:author" content="云雪">
<meta property="article:tag" content="maven">
<meta name="twitter:card" content="summary">
    
    
      
        
          <link rel="shortcut icon" href="/images/favicon.ico">
        
      
      
        
          <link rel="icon" type="image/png" href="/images/favicon-192x192.png" sizes="192x192">
        
      
      
        
          <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
        
      
    
    <!-- title -->
    <title>Maven</title>

    <!-- styles -->
    
<link rel="stylesheet" href="/css/style.css">


     <!-- 添加到这里！！ -->
     
<script src="/js/switch.js"></script>


    <!-- persian styles -->
    
    <!-- rss -->
    
    
	<!-- mathjax -->
	
<meta name="generator" content="Hexo 6.3.0"><link rel="alternate" href="/atom.xml" title="Cactus" type="application/atom+xml">
</head>

<body class="max-width mx-auto px3 ltr">
    
      <div id="header-post">
  <a id="menu-icon" href="#" aria-label="目录"><i class="fas fa-bars fa-lg"></i></a>
  <a id="menu-icon-tablet" href="#" aria-label="目录"><i class="fas fa-bars fa-lg"></i></a>
  <a id="top-icon-tablet" href="#" aria-label="顶部" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');" style="display:none;"><i class="fas fa-chevron-up fa-lg"></i></a>
  <span id="menu">
    <span id="nav">
      <ul>
        <!--
       --><li><a href="/">首页</a></li><!--
     --><!--
       --><li><a href="/about/">关于</a></li><!--
     --><!--
       --><li><a href="/archives/">归档</a></li><!--
     --><!--
       --><li><a href="/categories/">分类</a></li><!--
     --><!--
       --><li><a href="/search/">搜索</a></li><!--
     -->
      </ul>
    </span>
    <br/>
    <span id="actions">
      <ul>
        
        
        <li><a class="icon" aria-label="下一篇" href="/mysql/"><i class="fas fa-chevron-right" aria-hidden="true" onmouseover="$('#i-next').toggle();" onmouseout="$('#i-next').toggle();"></i></a></li>
        
        <li><a class="icon" aria-label="返回顶部" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up" aria-hidden="true" onmouseover="$('#i-top').toggle();" onmouseout="$('#i-top').toggle();"></i></a></li>
        <li><a class="icon" aria-label="分享文章" href="#"><i class="fas fa-share-alt" aria-hidden="true" onmouseover="$('#i-share').toggle();" onmouseout="$('#i-share').toggle();" onclick="$('#share').toggle();return false;"></i></a></li>

        <li><a class="icon" aria-label="切换主题 " href="#"><i class="fas fa-lightbulb" aria-hidden="true" onmouseover="$('#i-switch').toggle();" onmouseout="$('#i-switch').toggle();" onclick="switchNightMode();return false";></i></a></li>

      </ul>
      <span id="i-prev" class="info" style="display:none;">上一篇</span>
      <span id="i-next" class="info" style="display:none;">下一篇</span>
      <span id="i-top" class="info" style="display:none;">返回顶部</span>
      <span id="i-share" class="info" style="display:none;">分享文章</span>
      <span id="i-switch" class="info" style="display:none;">切换主题</span>
    </span>
    <br/>
    <div id="share" style="display: none">
      <ul>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.facebook.com/sharer.php?u=https://mihaoyou.gitee.io/Maven/"><i class="fab fa-facebook " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://twitter.com/share?url=https://mihaoyou.gitee.io/Maven/&text=Maven"><i class="fab fa-twitter " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.linkedin.com/shareArticle?url=https://mihaoyou.gitee.io/Maven/&title=Maven"><i class="fab fa-linkedin " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://pinterest.com/pin/create/bookmarklet/?url=https://mihaoyou.gitee.io/Maven/&is_video=false&description=Maven"><i class="fab fa-pinterest " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=Maven&body=Check out this article: https://mihaoyou.gitee.io/Maven/"><i class="fas fa-envelope " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://getpocket.com/save?url=https://mihaoyou.gitee.io/Maven/&title=Maven"><i class="fab fa-get-pocket " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://reddit.com/submit?url=https://mihaoyou.gitee.io/Maven/&title=Maven"><i class="fab fa-reddit " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.stumbleupon.com/submit?url=https://mihaoyou.gitee.io/Maven/&title=Maven"><i class="fab fa-stumbleupon " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://digg.com/submit?url=https://mihaoyou.gitee.io/Maven/&title=Maven"><i class="fab fa-digg " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.tumblr.com/share/link?url=https://mihaoyou.gitee.io/Maven/&name=Maven&description="><i class="fab fa-tumblr " aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://news.ycombinator.com/submitlink?u=https://mihaoyou.gitee.io/Maven/&t=Maven"><i class="fab fa-hacker-news " aria-hidden="true"></i></a></li>
</ul>

    </div>
    <div id="toc">
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#Maven"><span class="toc-number">1.</span> <span class="toc-text">Maven</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-Maven%E7%AE%80%E4%BB%8B%E5%92%8C%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8"><span class="toc-number">1.1.</span> <span class="toc-text">1.Maven简介和快速入门</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-1Maven%E4%BB%8B%E7%BB%8D"><span class="toc-number">1.1.1.</span> <span class="toc-text">1.1Maven介绍</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2Maven%E4%B8%BB%E8%A6%81%E4%BD%9C%E7%94%A8%E7%90%86%E8%A7%A3"><span class="toc-number">1.1.2.</span> <span class="toc-text">1.2Maven主要作用理解</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-3Maven%E5%AE%89%E8%A3%85%E5%92%8C%E9%85%8D%E7%BD%AE"><span class="toc-number">1.1.3.</span> <span class="toc-text">1.3Maven安装和配置</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-Maven%E9%A1%B9%E7%9B%AE%E5%B7%A5%E7%A8%8B%E7%BB%93%E6%9E%84%E8%AF%B4%E6%98%8E"><span class="toc-number">1.2.</span> <span class="toc-text">2.Maven项目工程结构说明</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-Maven%E6%A0%B8%E5%BF%83%E5%8A%9F%E8%83%BD%E4%BE%9D%E8%B5%96%E5%92%8C%E6%9E%84%E5%BB%BA%E7%AE%A1%E7%90%86"><span class="toc-number">1.3.</span> <span class="toc-text">3.Maven核心功能依赖和构建管理</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#3-1%E4%BE%9D%E8%B5%96%E7%AE%A1%E7%90%86%E5%92%8C%E9%85%8D%E7%BD%AE"><span class="toc-number">1.3.1.</span> <span class="toc-text">3.1依赖管理和配置</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-2%E4%BE%9D%E8%B5%96%E4%BC%A0%E9%80%92%E5%92%8C%E5%86%B2%E7%AA%81"><span class="toc-number">1.3.2.</span> <span class="toc-text">3.2依赖传递和冲突</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-3%E4%BE%9D%E8%B5%96%E5%AF%BC%E5%85%A5%E5%A4%B1%E8%B4%A5%E5%9C%BA%E6%99%AF%E5%92%8C%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88"><span class="toc-number">1.3.3.</span> <span class="toc-text">3.3依赖导入失败场景和解决方案</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-4%E6%89%A9%E5%B1%95%E6%9E%84%E5%BB%BA%E7%AE%A1%E7%90%86%E5%92%8C%E6%8F%92%E4%BB%B6%E9%85%8D%E7%BD%AE"><span class="toc-number">1.3.4.</span> <span class="toc-text">3.4扩展构建管理和插件配置</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-2Maven%E5%B7%A5%E7%A8%8B%E8%81%9A%E5%90%88%E5%85%B3%E7%B3%BB"><span class="toc-number">1.3.5.</span> <span class="toc-text">4.2Maven工程聚合关系</span></a></li></ol></li></ol></li></ol>
    </div>
  </span>
</div>

    
    <div class="content index py4">
        
        <article class="post" itemscope itemtype="http://schema.org/BlogPosting">
  <header>
    
    <h1 class="posttitle" itemprop="name headline">
        Maven
    </h1>



    <div class="meta">
      <span class="author" itemprop="author" itemscope itemtype="http://schema.org/Person">
        <span itemprop="name">云雪</span>
      </span>
      
    <div class="postdate">
      
        <time datetime="2023-09-15T13:40:13.000Z" itemprop="datePublished">2023-09-15</time>
        
      
    </div>


      
    <div class="article-category">
        <i class="fas fa-archive"></i>
        <a class="category-link" href="/categories/java/">java</a>
    </div>


      
    <div class="article-tag">
        <i class="fas fa-tag"></i>
        <a class="tag-link-link" href="/tags/maven/" rel="tag">maven</a>
    </div>


    </div>
  </header>
  

  <div class="content" itemprop="articleBody">
    <h2 id="Maven"><a href="#Maven" class="headerlink" title="Maven"></a>Maven</h2><h3 id="1-Maven简介和快速入门"><a href="#1-Maven简介和快速入门" class="headerlink" title="1.Maven简介和快速入门"></a>1.Maven简介和快速入门</h3><h4 id="1-1Maven介绍"><a href="#1-1Maven介绍" class="headerlink" title="1.1Maven介绍"></a>1.1Maven介绍</h4><ul>
<li><code>Maven</code>是一款为Java项目构建管理，依赖管理的工具（<strong>软件</strong>），使用Maven可以自动化构建、测试、打包和发布项目，大大提高了开发效率和质量</li>
<li>总结：<code>Maven</code>就是一个软件，掌握软件安装、配置、以及基本功能（<strong>项目构建</strong>、<strong>依赖管理</strong>）使用就是本课程的主要目标！</li>
</ul>
<h4 id="1-2Maven主要作用理解"><a href="#1-2Maven主要作用理解" class="headerlink" title="1.2Maven主要作用理解"></a>1.2Maven主要作用理解</h4><ol>
<li><p><strong>场景概念</strong>：</p>
<p><strong>场景</strong>1：例如我们项目需要第三方库（依赖），如<code>Druid</code>连接池、<code>MySQL</code>数据库和<code>Jackson</code>等，那么我们可以将需要的依赖项的信息编写到Maven工程的配置文件，Maven软件就会自动下载并复制这些依赖到项目中，也会下载依赖需要的依赖！确保依赖版本正确无冲突和依赖完整！</p>
<p><strong>场景****2</strong>：项目开发完成后，想要将项目打成war文件，并部署到服务器中运行，使用Maven软件，我们可以通过一行构建命令（<code>mvn package</code>）快速项目构建和打包！节省大量时间！</p>
</li>
<li><p><strong>依赖管理</strong>：</p>
<p>Maven可以管理项目的依赖，包括自动下载所需依赖库、自动下载所需要的依赖并且保证版本没有冲突、依赖版本管理等。通过Maven，我们可以方便维护项目所依赖的外部库，而我们仅仅需要编写配置即可</p>
</li>
<li><p><strong>构建管理</strong>：</p>
<p>项目构建是指将源代码、配置文件、资源文件等转化为能够运行或部署的应用程序或库的过程！Maven可以管理项目的编译、测试、打包、部署等构建过程，通过实现标准的构建生命周期，Maven可以确保每一个构建过程都遵循同样的规则和最佳实践，同时，Maven的插件机制也使得开发者可以对构建过程进行扩展的定制，主动触发构建，只需要简单的命令操作即可。</p>
</li>
</ol>
<h4 id="1-3Maven安装和配置"><a href="#1-3Maven安装和配置" class="headerlink" title="1.3Maven安装和配置"></a>1.3Maven安装和配置</h4><ul>
<li>下载Maven并解压</li>
<li>配置环境变量</li>
<li>更换为阿里镜像</li>
</ul>
<h3 id="2-Maven项目工程结构说明"><a href="#2-Maven项目工程结构说明" class="headerlink" title="2.Maven项目工程结构说明"></a>2.Maven项目工程结构说明</h3><ul>
<li>Maven是一个强大的构建工具，它提供一种标准化的项目结构，可以帮助开发者更容易的管理项目的依赖、构建、测试和发布任务，以下是Maven Web程序的文件结构及文件的作用：</li>
</ul>
<blockquote>
<p>|- -pom.xml										#Maven项目管理文件</p>
<p>|- -src				</p>
<p>​	|- - main										#项目主代码</p>
<p>​	|	| - -java									#Java源代码目录</p>
<p>​	|	|		- -com&#x2F;example&#x2F;myapp	#开发者代码主目录</p>
<p>​	|	|			|- -controller				#存放Controller层代码的目录</p>
<p>​	|	|			|- -service					#存放Service层代码的目录</p>
<p>​	|	|			|- -dao						#存放Dao层代码</p>
<p>​	|	|			.model						#存放数据模型的目录</p>
<p>​	|	| - -resources						#资源目录、存放配置文件、静态资源等</p>
<p>​	|	|	|- -log4j.properties			#日志配置文件</p>
<p>​	|	|	|- -spring-mybatis.xml		#Spring Mybatis 配置文件</p>
<p>​	|	|	..static								#存放静态资源目录</p>
<p>​	|	|		|- -css							#存放CSS文件的目录</p>
<p>​	|	|		|- -js								#存放JavaScript文件的目录</p>
<p>​	|	|		&#96;- -images						#存放图片资源的目录</p>
<p>​	|	&#96;- -webapp								#存放WEB相关配置和资源</p>
<p>​	|	|- -WEB-INF							#存放WEB应用配置文件</p>
<p>​	|	|		|- -web.xml					#web应用的部署描述文件</p>
<p>​	|	|		&#96;- -classes					#存放编译后的class文件</p>
<p>​	|	&#96;- -index.html						#web应用入口页面</p>
<p>​	&#96;- -test										#项目测试代码</p>
<p>​		|- -java									#单元测试目录</p>
<p>​		&#96;- -resources						#测试资源目录</p>
</blockquote>
<ul>
<li>pom.xml：Maven项目管理文件，用于描述项目的依赖和构建配置等信息</li>
<li>src&#x2F;main&#x2F;java：存放项目的Java源代码</li>
<li>src&#x2F;main&#x2F;resources：存放项目的资源文件，如配置文件、静态资源等</li>
<li>src&#x2F;main&#x2F;webapp&#x2F;WEB-INF：存放Web应用的入口页面</li>
<li>src&#x2F;test&#x2F;java：存放项目的测试代码</li>
<li>src&#x2F;test&#x2F;resources：存放测试相关的资源文件，如测试配置文件等</li>
</ul>
<h3 id="3-Maven核心功能依赖和构建管理"><a href="#3-Maven核心功能依赖和构建管理" class="headerlink" title="3.Maven核心功能依赖和构建管理"></a>3.Maven核心功能依赖和构建管理</h3><h4 id="3-1依赖管理和配置"><a href="#3-1依赖管理和配置" class="headerlink" title="3.1依赖管理和配置"></a>3.1依赖管理和配置</h4><ul>
<li><p>Maven依赖管理是Maven软件中最重要的功能之一，Maven的依赖管理能够帮助开发者人员自动解决软件包依赖问题，使得开发人员能够轻松将其他开发人员开发的模块或第三方框架集成自己的应用程序或模块中，避免出现版本冲突和依赖缺失等问题</p>
</li>
<li><p>我们通过通过定义POM文件，Maven能够自动解析项目的依赖关系，并通过Maven仓库自动下载和管理依赖，从而避免了手动下载和管理依赖的繁琐工作和可能引发的版本冲突问题</p>
</li>
<li><p>maven项目信息属性配置和读取：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;?xml version=<span class="string">&quot;1.0&quot;</span> encoding=<span class="string">&quot;UTF-8&quot;</span>?&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">project</span> <span class="attr">xmlns</span>=<span class="string">&quot;http://maven.apache.org/POM/4.0.0&quot;</span></span></span><br><span class="line"><span class="tag">		 <span class="attr">xmlns:xsi</span>=<span class="string">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span></span><br><span class="line"><span class="tag">		 <span class="attr">xsi:schemaLocation</span>=<span class="string">&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;</span>&gt;</span></span><br><span class="line">  <span class="comment">&lt;!--模型版本 --&gt;</span>  </span><br><span class="line">	<span class="tag">&lt;<span class="name">modelVersion</span>&gt;</span>4.0.0<span class="tag">&lt;/<span class="name">modelVersion</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 公司或者组织的唯一标识，并且配置生成的路径也是由此生成，如com.comparyname.project-gr--&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.mihayo<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- 项目的唯一ID，一个groupId下面可能多个项目，就是artifactId来区分的--&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>ams<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- 版本号--&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">version</span>&gt;</span>1.0-SNAPSHOT<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!--- maven工程的打包方式 java jar(默认值) web war   pom 不打包--&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">packaging</span>&gt;</span>jar<span class="tag">&lt;/<span class="name">packaging</span>&gt;</span></span><br><span class="line"></span><br><span class="line">    <span class="comment">&lt;!-- 声明版本号--&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">properties</span>&gt;</span></span><br><span class="line">        <span class="comment">&lt;!-- 声明一个变量以后，可以在其他的位置进行引用$&#123;jackson.version</span></span><br><span class="line"><span class="comment">			注意：声明的标签建议两层以上命名！version 2.3.7.RELEASE 推荐：技术名.version</span></span><br><span class="line"><span class="comment">		&#125;---&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">jackson.version</span>&gt;</span>2.3.7.RELEASE<span class="tag">&lt;/<span class="name">jackson.version</span>&gt;</span></span><br><span class="line">        </span><br><span class="line">		<span class="tag">&lt;<span class="name">maven.compiler.source</span>&gt;</span>8<span class="tag">&lt;/<span class="name">maven.compiler.source</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">maven.compiler.target</span>&gt;</span>8<span class="tag">&lt;/<span class="name">maven.compiler.target</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">project.build.sourceEncoding</span>&gt;</span>UTF-8<span class="tag">&lt;/<span class="name">project.build.sourceEncoding</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;/<span class="name">properties</span>&gt;</span></span><br><span class="line">    <span class="comment">&lt;!-- 第三方依赖信息声明--&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">dependencies</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-web<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">version</span>&gt;</span>$&#123;jackson.version&#125;<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-thymeleaf<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">version</span>&gt;</span>2.3.7.RELEASE<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-autoconfigure<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">version</span>&gt;</span>2.3.7.RELEASE<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>com.baomidou<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>mybatis-plus-boot-starter<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">version</span>&gt;</span>3.4.2<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>mysql<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>mysql-connector-java<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">version</span>&gt;</span>8.0.29<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;/<span class="name">dependencies</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;/<span class="name">project</span>&gt;</span></span><br></pre></td></tr></table></figure></li>
</ul>
<h4 id="3-2依赖传递和冲突"><a href="#3-2依赖传递和冲突" class="headerlink" title="3.2依赖传递和冲突"></a>3.2依赖传递和冲突</h4><ul>
<li>依赖传递：指的是当一个模块库A依赖于另一个模块或库B，而B又依赖于模块或库C，那么A会间接依赖于C，这种依赖传递结构可以形成一个依赖树，当我们引入一个库或框架时，构建工具如（<code>Maven</code>、<code>Gradle</code>）会自动解析和加载其所有的直接和间接依赖，确保这些依赖都可用</li>
<li>依赖传递的作用是：<ul>
<li><strong>减少重复以依赖</strong>：当多个项目依赖同一个库时，Maven可以自动下载并且只下载一次该库，这样可以减少项目的构建时间和磁盘空间</li>
<li><strong>自动管理依赖</strong>：Maven可以自动管理依赖项，使用依赖传递，简化了依赖项的管理，使项目结构更加可靠和一致</li>
<li><strong>确保依赖项版本正确性</strong>：通过依赖传递的依赖，之间都不会存在版本兼容性问题，确实依赖的版本正确性</li>
</ul>
</li>
<li>依赖冲突：发现已经存在依赖（重复依赖）会终止依赖传递！避免循环依赖重复依赖的问题<ul>
<li>依赖冲突的解决原则：第一原则：<ul>
<li>谁短谁优先！引用的路径长度</li>
<li>A-C-B 1.0</li>
<li>F-B 2.0</li>
<li>A-C-F-B 2.0</li>
</ul>
</li>
<li>第二原则：<ul>
<li>谁上谁优先！dependencies声明的先后顺序</li>
<li>A-B 1.0</li>
<li>F-B 2.0</li>
<li>A-F-B 1.0</li>
</ul>
</li>
</ul>
</li>
</ul>
<h4 id="3-3依赖导入失败场景和解决方案"><a href="#3-3依赖导入失败场景和解决方案" class="headerlink" title="3.3依赖导入失败场景和解决方案"></a>3.3依赖导入失败场景和解决方案</h4><ul>
<li>下载依赖时出现网络故障会仓库服务器宕机等原因，导致无法连接至Maven仓库，从而无法下载依赖</li>
<li>依赖项的版本号或配置文件中的版本号错误，或者依赖项没有正确定义，导致Maven下载的依赖项与实际需要的不一致，从而引发错误</li>
<li>本地Maven仓库或缓存被污染或损坏，导致Maven无法正确地使用现有的依赖项，并且也无法重新下载！</li>
<li>解决方案：<ul>
<li>检查网络连接和Maven仓库服务器状态</li>
<li>确保依赖项的版本号与项目对应的版本号匹配，并检查POM文件中的依赖项是否正确</li>
<li>清除本地Maven仓库缓存（<code>lastUpdated</code>文件），因为只要存在<code>lastUpdated</code>缓存文件，刷新也不会重新下载，本地仓库中，根据依赖度的gav属性依次向下查找文件夹，最终删除内部的文件，刷新重新下载即可！</li>
</ul>
</li>
</ul>
<h4 id="3-4扩展构建管理和插件配置"><a href="#3-4扩展构建管理和插件配置" class="headerlink" title="3.4扩展构建管理和插件配置"></a>3.4扩展构建管理和插件配置</h4><ul>
<li><p>构建概念</p>
<ul>
<li>项目构建是指将源代码、依赖库和资源文件等转化成可执行或可部署的应用程序的过程，在这个过程中包括编译源代码、链接依赖打包和部署等多个步骤</li>
<li><strong>清理 - 编译 - 测试 - 报告 - 打包 - 部署</strong></li>
</ul>
</li>
<li><p>主动触发场景</p>
<ul>
<li>重新编译：编译不充分，部分文件没有被编译</li>
<li>打包：独立部署到外部服务器软件，打包部署</li>
<li>部署本地或者私服服务器：maven工程加入到本地或者私服仓库，供其他工程使用</li>
</ul>
</li>
<li><p>命令方式构建：</p>
<p>语法：mvn 构建命令 构建命令…</p>
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td><code>mvn clean</code></td>
<td>清除编译或者打包后的项目结构，删除target文件夹</td>
</tr>
<tr>
<td><code>mvn compile</code></td>
<td>编译项目，生成target文件</td>
</tr>
<tr>
<td><code>mvn test</code></td>
<td>执行测试源码（测试）</td>
</tr>
<tr>
<td><code>mvn site</code></td>
<td>生成一个项目依赖信息的展示页面</td>
</tr>
<tr>
<td><code>mvn package</code></td>
<td>打包项目，生成war&#x2F;jar文件</td>
</tr>
<tr>
<td><code>mvn install</code></td>
<td>打包后上传到maven本地仓库（本地部署）</td>
</tr>
<tr>
<td><code>mvn deploy</code></td>
<td>只打包，上传到maven私服仓库（私服部署）</td>
</tr>
</tbody></table>
</li>
<li><p>构建命令周期：</p>
<p>构建命令周期可以理解成是一个固定构建命令的有序集合，触发周期后的命令，触发周期后的命令，会自动触发周期前的命令！也是一种简化构建的命令</p>
<ul>
<li>清理周期：主要是对项目编译生成文件进行清理</li>
<li>默认周期：定义了真正构件时所需要执行的所有步骤，它是生命周期中最核心的部分</li>
<li>报告周期：</li>
</ul>
</li>
<li><p>最佳使用方案：</p>
<ul>
<li>打包：<code>mvn clean package</code></li>
<li>重新编译：<code>mvn clean compile</code></li>
<li>本地部署：<code>mvn clean install</code></li>
</ul>
</li>
<li><p>周期，命令和插件</p>
<ul>
<li><p>周期-&gt;包含若干命令-&gt;若干插件</p>
</li>
<li><p>使用周期命令构建，简化构建过程！</p>
</li>
<li><p>最终进行构建的是插件！</p>
</li>
<li><pre><code class="xml">&lt;build&gt;
    &lt;plugins&gt;
        &lt;plugin&gt;
               &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
            &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
               &lt;version&gt;3.2.2&lt;/version&gt;
        &lt;/plugin&gt;        
    &lt;/plugins&gt;
&lt;/build&gt;
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br><span class="line">### 4.Maven继承和聚合特性</span><br><span class="line"></span><br><span class="line">#### 4.1Maven工程继承关系</span><br><span class="line"></span><br><span class="line">- 继承概念：</span><br><span class="line"></span><br><span class="line">  - Maven继承是指在Maven的项目中，让一个项目从另一个项目中继承配置信息的机制。继承可以让我们在多个项目中共享同一个配置信息，简化项目的管理和维护工作</span><br><span class="line"></span><br><span class="line">- 继承作用：</span><br><span class="line"></span><br><span class="line">  - 它的背景是：</span><br><span class="line">    - 对一个比较大型的项目进行了模块拆分</span><br><span class="line">    - 一个project下面，创建了很多个module</span><br><span class="line">    - 每一个module都需要配置自己的依赖信息</span><br><span class="line">  - 它的背后的需求是：</span><br><span class="line">    - 多个模块要使用同一个框架，它们应该是同一个版本，所以整个项目中使用的框架版本是需要统一管理</span><br><span class="line">    - 使用框架时所需要的jar包组合（或者说依赖信息组合）需要经过长期探索和反复调试最终确定一个可用组合。这个耗费很大精力总结出来的方案不应该在新项目中重新探索。</span><br><span class="line">  - 通过在父工程中为整个项目维护依赖信息的组合既保证了整个项目使用规范、准确的jar包；又能够将以往的经验沉淀下来，节约时间和精力</span><br><span class="line"></span><br><span class="line">- 继承的语法</span><br><span class="line"></span><br><span class="line">  - 父工程</span><br><span class="line"></span><br><span class="line">  ```xml</span><br><span class="line">  &lt;groupId&gt;org.mihayo&lt;/groupId&gt;</span><br><span class="line">  &lt;artifactId&gt;pro03-maven-parent&lt;/artifactId&gt;</span><br><span class="line">  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;</span><br><span class="line">  &lt;!-- 当前工程作为父工程，它需要去管理子工程，所以打包方式必须是pom--&gt;</span><br><span class="line">  &lt;packaging&gt;pom&lt;/packaging&gt;</span><br></pre></td></tr></table></figure>
</code></pre>
</li>
<li><p>子工程</p>
</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 使用parent标签指定当前工程的父工程--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">parent</span>&gt;</span></span><br><span class="line"> <span class="comment">&lt;!--- 父工程的坐标--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.mihayo<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>pro03-maven-parent<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">version</span>&gt;</span>1.0-SNAPSHOT<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">parent</span>&gt;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="comment">&lt;!-- 子工程的坐标--&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 如果子工程坐标中的groupId和version与父工程一致，那么可以省略--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.mihayo<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>pro04-maven-parent<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">version</span>&gt;</span>1.0-SNAPSHOT<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>父工程依赖统一管理</p>
<ul>
<li>父工程声明版本</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 使用dependencyManagement标签配置对依赖的管理--&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 被管理的依赖并没有真正被引入到工程--&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">dependencyManagement</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">dependencies</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-web<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">version</span>&gt;</span>2.3.7.RELEASE<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;<span class="name">dependency</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.springframework.boot<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>spring-boot-starter-thymeleaf<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">			<span class="tag">&lt;<span class="name">version</span>&gt;</span>2.3.7.RELEASE<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">		<span class="tag">&lt;/<span class="name">dependency</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;/<span class="name">dependencies</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">dependencyManagement</span>&gt;</span></span><br></pre></td></tr></table></figure></li>
</ul>
<h4 id="4-2Maven工程聚合关系"><a href="#4-2Maven工程聚合关系" class="headerlink" title="4.2Maven工程聚合关系"></a>4.2Maven工程聚合关系</h4><ul>
<li><p>聚合概念：</p>
<ul>
<li>Maven聚合是指将多个项目组织到一个父级项目中，通过触发父工程的构建，统一按顺序触发子工程构建的过程！</li>
</ul>
</li>
<li><p>聚合作用：</p>
<ul>
<li>统一管理子项目构建：通过聚合，可以将多个子项目组织在一起，方便管理和维护</li>
<li>优化构建顺序：通过聚合，可以多多个项目进行顺序控制，避免出现构建依赖混乱导致构建失败的情况</li>
</ul>
</li>
<li><p>聚合语法：</p>
<ul>
<li>父项目中包含子项目列表</li>
</ul>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">project</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">groupId</span>&gt;</span>org.mihayo<span class="tag">&lt;/<span class="name">groupId</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">artifactId</span>&gt;</span>parent-project<span class="tag">&lt;/<span class="name">artifactId</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">version</span>&gt;</span>1.0-SNAPSHOT<span class="tag">&lt;/<span class="name">version</span>&gt;</span></span><br><span class="line">	<span class="tag">&lt;<span class="name">packaging</span>&gt;</span>pom<span class="tag">&lt;/<span class="name">packaging</span>&gt;</span></span><br><span class="line">    </span><br><span class="line">    <span class="tag">&lt;<span class="name">modules</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">module</span>&gt;</span>child-project1<span class="tag">&lt;/<span class="name">module</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">module</span>&gt;</span>child-project2<span class="tag">&lt;/<span class="name">module</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">modules</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">project</span>&gt;</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>聚合演示：</p>
<ul>
<li>通过触发父工程构建命令，引发所有子模块构建！产生反应堆！</li>
</ul>
</li>
</ul>

  </div>
  <div id="copyright"><style>#easter-egg{border:0;padding:10px 0;position:relative}#easter-egg::before{font-family:"Font Awesome 5 Free";font-weight:900;content:"本文结束 \f1b0  感谢阅读";position:absolute;
padding:0 10px;
line-height:1px;
white-space:nowrap;
left:50%;
transform:translateX(-50%)}
</style><hr id="easter-egg"><blockquote style="padding:0">
    <p>作者: <a href="https://mihaoyou.gitee.io">
        <a1>云静</a1>
    </a></p>
    <p>版权声明: 本博客所有文章除特别声明外, 均采用 <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)"><a1>CC BY-NC-ND 4.0</a1></a> 许可协议, 转载请注明出处！</p></blockquote><hr></div>
</article>


    <div class="blog-post-comments">
        <div id="utterances_thread">
            <noscript>加载评论需要在浏览器启用 JavaScript 脚本支持。</noscript>
        </div>
    </div>


        
          <div id="footer-post-container">
  <div id="footer-post">

    <div id="nav-footer" style="display: none">
      <ul>
         
          <li><a href="/">首页</a></li>
         
          <li><a href="/about/">关于</a></li>
         
          <li><a href="/archives/">归档</a></li>
         
          <li><a href="/categories/">分类</a></li>
         
          <li><a href="/search/">搜索</a></li>
        
      </ul>
    </div>

    <div id="toc-footer" style="display: none">
      <ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#Maven"><span class="toc-number">1.</span> <span class="toc-text">Maven</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-Maven%E7%AE%80%E4%BB%8B%E5%92%8C%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8"><span class="toc-number">1.1.</span> <span class="toc-text">1.Maven简介和快速入门</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-1Maven%E4%BB%8B%E7%BB%8D"><span class="toc-number">1.1.1.</span> <span class="toc-text">1.1Maven介绍</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-2Maven%E4%B8%BB%E8%A6%81%E4%BD%9C%E7%94%A8%E7%90%86%E8%A7%A3"><span class="toc-number">1.1.2.</span> <span class="toc-text">1.2Maven主要作用理解</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#1-3Maven%E5%AE%89%E8%A3%85%E5%92%8C%E9%85%8D%E7%BD%AE"><span class="toc-number">1.1.3.</span> <span class="toc-text">1.3Maven安装和配置</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-Maven%E9%A1%B9%E7%9B%AE%E5%B7%A5%E7%A8%8B%E7%BB%93%E6%9E%84%E8%AF%B4%E6%98%8E"><span class="toc-number">1.2.</span> <span class="toc-text">2.Maven项目工程结构说明</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-Maven%E6%A0%B8%E5%BF%83%E5%8A%9F%E8%83%BD%E4%BE%9D%E8%B5%96%E5%92%8C%E6%9E%84%E5%BB%BA%E7%AE%A1%E7%90%86"><span class="toc-number">1.3.</span> <span class="toc-text">3.Maven核心功能依赖和构建管理</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#3-1%E4%BE%9D%E8%B5%96%E7%AE%A1%E7%90%86%E5%92%8C%E9%85%8D%E7%BD%AE"><span class="toc-number">1.3.1.</span> <span class="toc-text">3.1依赖管理和配置</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-2%E4%BE%9D%E8%B5%96%E4%BC%A0%E9%80%92%E5%92%8C%E5%86%B2%E7%AA%81"><span class="toc-number">1.3.2.</span> <span class="toc-text">3.2依赖传递和冲突</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-3%E4%BE%9D%E8%B5%96%E5%AF%BC%E5%85%A5%E5%A4%B1%E8%B4%A5%E5%9C%BA%E6%99%AF%E5%92%8C%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88"><span class="toc-number">1.3.3.</span> <span class="toc-text">3.3依赖导入失败场景和解决方案</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-4%E6%89%A9%E5%B1%95%E6%9E%84%E5%BB%BA%E7%AE%A1%E7%90%86%E5%92%8C%E6%8F%92%E4%BB%B6%E9%85%8D%E7%BD%AE"><span class="toc-number">1.3.4.</span> <span class="toc-text">3.4扩展构建管理和插件配置</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-2Maven%E5%B7%A5%E7%A8%8B%E8%81%9A%E5%90%88%E5%85%B3%E7%B3%BB"><span class="toc-number">1.3.5.</span> <span class="toc-text">4.2Maven工程聚合关系</span></a></li></ol></li></ol></li></ol>
    </div>

    <div id="share-footer" style="display: none">
      <ul>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.facebook.com/sharer.php?u=https://mihaoyou.gitee.io/Maven/"><i class="fab fa-facebook fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://twitter.com/share?url=https://mihaoyou.gitee.io/Maven/&text=Maven"><i class="fab fa-twitter fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.linkedin.com/shareArticle?url=https://mihaoyou.gitee.io/Maven/&title=Maven"><i class="fab fa-linkedin fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://pinterest.com/pin/create/bookmarklet/?url=https://mihaoyou.gitee.io/Maven/&is_video=false&description=Maven"><i class="fab fa-pinterest fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="mailto:?subject=Maven&body=Check out this article: https://mihaoyou.gitee.io/Maven/"><i class="fas fa-envelope fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://getpocket.com/save?url=https://mihaoyou.gitee.io/Maven/&title=Maven"><i class="fab fa-get-pocket fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://reddit.com/submit?url=https://mihaoyou.gitee.io/Maven/&title=Maven"><i class="fab fa-reddit fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.stumbleupon.com/submit?url=https://mihaoyou.gitee.io/Maven/&title=Maven"><i class="fab fa-stumbleupon fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://digg.com/submit?url=https://mihaoyou.gitee.io/Maven/&title=Maven"><i class="fab fa-digg fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="http://www.tumblr.com/share/link?url=https://mihaoyou.gitee.io/Maven/&name=Maven&description="><i class="fab fa-tumblr fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" target="_blank" rel="noopener" href="https://news.ycombinator.com/submitlink?u=https://mihaoyou.gitee.io/Maven/&t=Maven"><i class="fab fa-hacker-news fa-lg" aria-hidden="true"></i></a></li>
</ul>

    </div>

    <div id="actions-footer">
        <a id="menu" class="icon" href="#" onclick="$('#nav-footer').toggle();return false;"><i class="fas fa-bars fa-lg" aria-hidden="true"></i> 菜单</a>
        <a id="toc" class="icon" href="#" onclick="$('#toc-footer').toggle();return false;"><i class="fas fa-list fa-lg" aria-hidden="true"></i> 目录</a>
        <a id="share" class="icon" href="#" onclick="$('#share-footer').toggle();return false;"><i class="fas fa-share-alt fa-lg" aria-hidden="true"></i> 分享</a>
        <a id="top" style="display:none" class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up fa-lg" aria-hidden="true"></i> 返回顶部</a>
    </div>

  </div>
</div>

        
        <footer id="footer">
      <div class="footer-left">
        Copyright &copy;
        
        
        2022-2023
        云雪
      </div>
      <div class="footer-right">
        <nav>
          <ul>
            <!--
          --><li><a href="/">首页</a></li><!--
        --><!--
          --><li><a href="/about/">关于</a></li><!--
        --><!--
          --><li><a href="/archives/">归档</a></li><!--
        --><!--
          --><li><a href="/categories/">分类</a></li><!--
        --><!--
          --><li><a href="/search/">搜索</a></li><!--
        -->
          </ul>
          <ul>
          
              <!-- 不蒜子统计 -->
              <span id="busuanzi_container_site_pv">
                  本站总访问量<span id="busuanzi_value_site_pv"></span>次
              </span>
              <span class="post-meta-divider">|</span>
              <span id="busuanzi_container_site_uv" style='display:none'>
                      本站访客数<span id="busuanzi_value_site_uv"></span>人
              </span>
            <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
            
          </ul>
        </nav>
      </div>
      
</footer>


    </div>
    <!-- styles -->



  <link rel="preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css" crossorigin="anonymous" onload="this.onload=null;this.rel='stylesheet'"/>


    <!-- jquery -->
 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" crossorigin="anonymous"></script> 




<!-- clipboard -->

  
    <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.7/clipboard.min.js" crossorigin="anonymous"></script> 
  
  <script type="text/javascript">
  $(function() {
    // copy-btn HTML
    var btn = "<span class=\"btn-copy tooltipped tooltipped-sw\" aria-label=\"复制到粘贴板！\">";
    btn += '<i class="far fa-clone"></i>';
    btn += '</span>'; 
    // mount it!
    $(".highlight table").before(btn);
    var clip = new ClipboardJS('.btn-copy', {
      text: function(trigger) {
        return Array.from(trigger.nextElementSibling.querySelectorAll('.code')).reduce((str,it)=>str+it.innerText+'\n','')
      }
    });
    clip.on('success', function(e) {
      e.trigger.setAttribute('aria-label', "复制成功！");
      e.clearSelection();
    })
  })
  </script>


<script src="/js/main.js"></script>

<!-- search -->

<!-- Google Analytics -->

<!-- Baidu Analytics -->

  <script type="text/javascript">
        var _hmt = _hmt || [];
        (function() {
          var hm = document.createElement("script");
          hm.src = "https://hm.baidu.com/hm.js?d052d72734717a430b46e4d07257350b";
          var s = document.getElementsByTagName("script")[0];
          s.parentNode.insertBefore(hm, s);
        })();
        </script>

<!-- Cloudflare Analytics -->

<!-- Umami Analytics -->

<!-- Disqus Comments -->

<!-- utterances Comments -->

    <script type="text/javascript">
      var utterances_repo = 'mihaoyou/huayu';
      var utterances_issue_term = 'pathname';
      var utterances_label = 'Comment';
      var utterances_theme = 'github-dark';

      (function(){
          var script = document.createElement('script');

          script.src = 'https://utteranc.es/client.js';
          script.setAttribute('repo', utterances_repo);
          script.setAttribute('issue-term', 'pathname');
          script.setAttribute('label', utterances_label);
          script.setAttribute('theme', utterances_theme);
          script.setAttribute('crossorigin', 'anonymous');
          script.async = true;
          (document.getElementById('utterances_thread')).appendChild(script);
      }());
  </script>

</body>
</html>
